/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hxg.portmgr.core.oper.snmp;

import hxg.portmgr.core.oper.snmp.oidgroup.RemoteValueType;
import org.snmp4j.smi.Variable;

/**
 *
 * @author hxg
 */
public class Value {

    long value=-1;
    String strvalue;
    RemoteValueType type;

    public Value(Variable var, RemoteValueType type) {
        this.type=type;
        switch (type) {
            case NumberValue:
                value = var.toLong();
            case StringValue:
                strvalue = var.toString();
        }
    }

    public void setLongValue(long value) {
        this.value = value;
    }

    public void setStringValue(String strval) {
        this.strvalue = strval;
    }

    public long longValue() {
        switch (type) {
            case NumberValue:
                return value;
            case StringValue:
                return -1;
        }
        return -1;
    }

    @Override
    public String toString() {
        switch (type) {
            case NumberValue:
                return Long.toString(value);
            case StringValue:
                return strvalue;
        }
        return "";
    }
}
